package com.elite.groovy.kh;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.tinet.clink.cc.request.cdr.*;
import com.tinet.clink.cc.response.cdr.*;
import com.tinet.clink.core.client.Client;
import com.tinet.clink.core.client.ClientConfiguration;
import com.tinet.clink.core.exceptions.ClientException;
import com.tinet.clink.core.exceptions.ServerException;
import org.junit.Test;

/**
 * 通话记录单元测试
 *
 * @author huwk
 * @date 2018/10/23
 */
public class CdrRecord {

    ObjectMapper mapper = new ObjectMapper();

    // 创建访问服务的client实例并初始化
    private static ClientConfiguration configuration = new ClientConfiguration("ea4478dba2ca33fc67fe0b1f43df5430", "5T5q9u1cNSB2234Gio8L");

    private static Client client = null;
    /**
     * 呼入通话记录列表单元测试
     */
    @Test
    public void listCdrIbsTest() throws ServerException, ClientException, JsonProcessingException {

        configuration.setScheme("http");
        configuration.setHost("api-sh.clink.cn");
        client = new Client(configuration);

        ListCdrIbsRequest request = new ListCdrIbsRequest();
        request.setHiddenType(0);
        request.setStartTime(1687968000L);
        request.setEndTime(1688054399L);
        request.setLimit(100);
        request.setOffset(100);
        ListCdrIbsResponse response = client.getResponseModel(request);
        System.out.println(mapper.writeValueAsString(response.getCdrIbs()));
    }
    /**
     * 呼入通话记录详情单元测试
     */
    @Test
    public void describeCdrIbTest() throws ServerException, ClientException, JsonProcessingException {

        DescribeCdrIbRequest request = new DescribeCdrIbRequest();
        request.setMainUniqueId("medias_2-1687253324.131789");
        request.setHiddenType(1);
        DescribeCdrIbResponse response = client.getResponseModel(request);
        System.out.println(mapper.writeValueAsString(response.getCdrIb()));
    }

}

